#include "SdkWatchingHandle.h"
#include "InPerUartHandle.h"
#include "SdkHardware.h"
#include "tuya_ipc_p2p.h"
#include "InPerLed.h"

#define DEF_TAG             "Watching"

Com_u8 g_SdkWatching_Flag = DEF_COM_FALSE;

Com_void Ext_SdkWatching_Handle(Com_void)
{
    static Com_s8 w_led_flag = DEF_COM_FALSE;
    UINT_T client_num = 0;
    CLIENT_CONNECT_INFO_S *conn_info = NULL;
    tuya_ipc_get_client_conn_info(&client_num,&conn_info);

    if((client_num == 0) && (w_led_flag == DEF_COM_TRUE))
    {
        w_led_flag = DEF_COM_FALSE;
        Ext_InComFile_JudgeRemove(DEF_FLAG_USER_WATCHING);
    }
    else if(client_num > 0)
    {
        Ext_InPerLed_CtrlStatus(DEF_COM_FALSE);
        if(w_led_flag == DEF_COM_FALSE)
        {
            w_led_flag = DEF_COM_TRUE;
        }
        Ext_InComFile_JudgeCreat(DEF_FLAG_USER_WATCHING);
    }
}

